﻿using System;
using System.Text;

namespace dotHTML.HTML {
    /// <summary>
    /// Represents the base URL for all URLs in the document.
    /// </summary>
    [Standalone]
    [Serializable]
    public class Base : Element {
        private string _href;
        private string _target;

        /// <summary>
        /// Constructs a new Base element.
        /// </summary>
        public Base() { }

        /// <summary>
        /// Constructs a new Base element with the given path.
        /// </summary>
        /// <param name="href"></param>
        public Base(string href) {
            _href = href;
        }

        /// <summary>
        /// Gets or sets the base URL for all URLs in the document.
        /// </summary>
        public string Href {
            get { return _href; }
            set { _href = value; }
        }

        /// <summary>
        /// Gets or sets the target frame for links.
        /// </summary>
        public string Target {
            get { return _target; }
            set { _target = value; }
        }

        /// <summary>
        /// Gets a formatted string of all local attributes of this element
        /// (not including the base attributes).
        /// </summary>
        /// <param name="sb">The StringBuilder to write this element's
        /// attribute data to.</param>
        protected override void WriteLocalAttributes(StringBuilder sb) {
            AttributeWriter.Write(sb, _href, "href");
            AttributeWriter.Write(sb, _target, "target");
        }
    }
}
